package com.whxd.framework.security;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

/**
 * 调整登录后的页面到首页，不到原请求页
 * 
 * @author 张世鹏
 * @since 2013-6-20
 */
public class FrameworkAuthenticationSuccessHandler implements AuthenticationSuccessHandler {

	public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
			Authentication authentication) throws IOException, ServletException {
//		FrameworkUserDetails user = (FrameworkUserDetails) authentication.getPrincipal();
//		request.getSession().setAttribute("SPARK_USER", user);
//		response.reset();//TODO：清空头信息，可能解决response错误的问题
		response.sendRedirect(request.getContextPath()+"/main");
	}

}